# -*- coding: utf-8 -*-
from PyQt5 import QtWidgets
from gui.data_analysis.multiple_curves_setting import Ui_Dialog
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from utils.color_util import color
from utils.log_util import loggings as logger


class MultipleCurvesWindow(QtWidgets.QDialog, Ui_Dialog):
    dialogSignal = pyqtSignal(object, object)
    selectedSignal = pyqtSignal(object)

    def __init__(self):
        super().__init__()
        self.setupUi(self)
        icon = QIcon()
        icon.addPixmap(
            QPixmap("icons/logo.ico"),
            QIcon.Normal,
            QIcon.Off)
        self.setWindowIcon(icon)
        self.cbb_chip_name.currentTextChanged.connect(self.select_chip)

    def select_chip(self,text):
        if text:
            self.selectedSignal.emit(text)

    def set_para_2_widget(self, test_para):
        self.cbb_para.clear()
        self.cbb_para.addItems(test_para)

    def set_chip_list_2_widget(self, chip_list):
        self.cbb_chip_name.clear()
        self.cbb_chip_name.addItems(chip_list)

    # def set_shot_position_list_2_widget(self, shot_list):
    #     self.cbb_shot_position.clear()
    #     self.cbb_shot_position.addItems(shot_list)

    @pyqtSlot()
    def on_btnEnsure_clicked(self):
        test_para = self.cbb_para.currentText().strip()
        chip_name = self.cbb_chip_name.currentText().strip()
        # shot_name = self.cbb_shot_position.currentText().strip() and shot_name
        if test_para and chip_name:
            self.dialogSignal.emit(test_para, chip_name)
            # self.close()

    def show_notification(self, title, content):
        QMessageBox.information(self, title, content, QMessageBox.Yes, QMessageBox.Yes)

    @pyqtSlot()
    def on_btnCancel_clicked(self):
        self.close()
